<template>
  <!--  -->
  <div>
    <div class="nav-box" :style="[{ 'padding-top': top }]">
      <div class="nav-content flex">
        <div class="nav-back flex" v-if="needBack" @click="back">
          <img class="back-img" src="@/assets/icon/back.png" alt="" />
        </div>
        <div class="nav-title flex">{{ title }}</div>
      </div>
    </div>
    <div v-if="needSeat" class="seat-box" :style="[{ 'padding-top': top }]">
      <div class="seat"></div>
    </div>
  </div>
</template>

<script setup>
import $common from "@/utils/$common";
import $router from "@/utils/$router";
const systemInfo =
  $common.getlocalStorage("systemInfo") || uni.getSystemInfoSync();
const top = systemInfo.statusBarHeight + "px";

const props = defineProps({
  //标题
  title: {
    default: "",
  },
  //是否需要占位盒子
  needSeat: {
    type: Boolean,
    default: true,
  },
  //是否显示返回按钮
  needBack: {
    type: Boolean,
    default: true,
  },
});

function back() {
  $router.back();
}
</script>
<style lang="scss" scoped>
.nav-box {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 10;
  .nav-content {
    height: 44px;
    .nav-back {
      position: absolute;
      left: 0;
      z-index: 1;
      padding: 0 24rpx 0 24rpx;
      height: 100%;
      .back-img {
        width: 20px;
        height: 20px;
      }
    }
    .nav-title {
      font-size: 18px;
      font-weight: 500;
      padding: 0 40rpx;
    }
  }
}
.seat-box {
  opacity: 0;
  .seat {
    height: 44px;
  }
}
</style>
